home *** CD-ROM | disk | FTP | other *** search
/ Dr. Windows 3 / dr win3.zip / dr win3 / PROGRAMR / OLE2BOOK.ZIP / CHAP05.ZIP / CHAP05 / SCHMOO / POLYLINE.H < prev    next >
C/C++ Source or Header  |  1993-03-23  |  5KB  |  164 lines

  1. /*
  2.  * POLYLINE.H
  3.  *
  4.  * Definitions and function prototypes for the PolyLine window class
  5.  * that can be treated like its own control.
  6.  *
  7.  * Copyright (c)1993 Microsoft Corporation, All Rights Reserved
  8.  *
  9.  * Kraig Brockschmidt, Software Design Engineer
  10.  * Microsoft Systems Developer Relations
  11.  *
  12.  * Internet  :  kraigb@microsoft.com
  13.  * Compuserve:  >INTERNET:kraigb@microsoft.com
  14.  */
  15.  
  16.  
  17. #ifndef _POLYLINE_H_
  18. #define _POLYLINE_H_
  19.  
  20. //Versioning.
  21. #define VERSIONMAJOR                2
  22. #define VERSIONMINOR                0
  23. #define VERSIONCURRENT              0x00020000
  24.  
  25. //Classname
  26. #define SZCLASSPOLYLINE             "polyline"
  27.  
  28. #define HIMETRIC_PER_INCH           2540
  29. #define CPOLYLINEPOINTS             20
  30.  
  31. //Window extra bytes and offsets
  32. #define CBPOLYLINEWNDEXTRA          (sizeof(LONG))
  33. #define PLWL_STRUCTURE              0
  34.  
  35.  
  36. //Version 2.0 Polyline Structure
  37. typedef struct __far tagPOLYLINEDATA
  38.     {
  39.     WORD        wVerMaj;                //Major version number.
  40.     WORD        wVerMin;                //Minor version number.
  41.     WORD        cPoints;                //Number of points.
  42.     BOOL        fReserved;              //Previously fDrawEntire, obsoleted
  43.     RECT        rc;                     //Rectangle of this figure (client)
  44.     POINT       rgpt[CPOLYLINEPOINTS];  //Array of points on 0-32767 grid.
  45.  
  46.     //Version 2.0 additions
  47.     COLORREF    rgbBackground;          //Background color
  48.     COLORREF    rgbLine;                //Line color
  49.     int         iLineStyle;             //Line style
  50.     } POLYLINEDATA, FAR *LPPOLYLINEDATA;
  51.  
  52. #define CBPOLYLINEDATA   sizeof(POLYLINEDATA)
  53. #define CBPOLYLINEDATA20 sizeof(POLYLINEDATA)
  54.  
  55.  
  56. //Version 1.0 Polyline Structure
  57. typedef struct __far tagPOLYLINEDATA10
  58.     {
  59.     WORD        wVerMaj;                //Major version number.
  60.     WORD        wVerMin;                //Minor version number.
  61.     WORD        cPoints;                //Number of points.
  62.     BOOL        fDrawEntire;            //Flag to draw entire figure.
  63.     RECT        rc;                     //Rectangle of this figure (parent)
  64.     POINT       rgpt[CPOLYLINEPOINTS];  //Array of points scaled to rc
  65.     } POLYLINEDATA10, FAR *LPPOLYLINEDATA10;
  66.  
  67. #define CBPOLYLINEDATA10 sizeof(POLYLINEDATA10)
  68.  
  69.  
  70. //POLYWIN.CPP
  71. LRESULT __export FAR PASCAL PolylineWndProc(HWND, UINT, WPARAM, LPARAM);
  72.  
  73.  
  74.  
  75. class __far CPolyline : public CWindow
  76.     {
  77.     friend LRESULT __export FAR PASCAL PolylineWndProc(HWND, UINT, WPARAM, LPARAM);
  78.  
  79.     private:
  80.         POLYLINEDATA   m_pl;
  81.  
  82.         class CPolylineAdviseSink FAR * m_pAdv;
  83.  
  84.     private:
  85.         void      PointScale(LPRECT, LPPOINT, BOOL);
  86.         void      Draw(HDC, BOOL, BOOL);
  87.         void      RectConvertMappings(LPRECT, BOOL);
  88.  
  89.     public:
  90.         CPolyline(HINSTANCE);
  91.         ~CPolyline(void);
  92.  
  93.         BOOL      FInit(HWND, LPRECT, DWORD, UINT, class CPolylineAdviseSink FAR *);
  94.  
  95.         void      New(void);
  96.         BOOL      Undo(void);
  97.  
  98.         //File functions
  99.         //CHAPTER5MOD
  100.         LONG      ReadFromStorage(LPSTORAGE);
  101.         LONG      WriteToStorage(LPSTORAGE, LONG);
  102.         //End CHAPTER5MOD
  103.         LONG      ReadFromFile(LPSTR);
  104.         LONG      WriteToFile(LPSTR, LONG);
  105.  
  106.         //Data transfer functions
  107.         LONG      DataSet(LPPOLYLINEDATA, BOOL, BOOL);
  108.         LONG      DataGet(LPPOLYLINEDATA, LONG);
  109.         LONG      DataSetMem(HGLOBAL, BOOL, BOOL, BOOL);
  110.         LONG      DataGetMem(LONG, HGLOBAL FAR *);
  111.         HBITMAP   RenderBitmap(void);
  112.         HMETAFILE RenderMetafile(void);
  113.         HGLOBAL   RenderMetafilePict(void);
  114.  
  115.         void      RectGet(LPRECT);
  116.         void      SizeGet(LPRECT);
  117.         void      RectSet(LPRECT, BOOL);
  118.         void      SizeSet(LPRECT, BOOL);
  119.         COLORREF  ColorSet(UINT, COLORREF);
  120.         COLORREF  ColorGet(UINT);
  121.         UINT      LineStyleSet(UINT);
  122.         UINT      LineStyleGet(void);
  123.     };
  124.  
  125. typedef CPolyline FAR * LPCPolyline;
  126.  
  127.  
  128. //Error values for data transfer functions
  129. #define POLYLINE_E_NONE                    0
  130. #define POLYLINE_E_UNSUPPORTEDVERSION      -1
  131. #define POLYLINE_E_INVALIDPOINTER          -2
  132. #define POLYLINE_E_READFAILURE             -3
  133. #define POLYLINE_E_WRITEFAILURE            -4
  134.  
  135.  
  136.  
  137.  
  138. class __far CPolylineAdviseSink
  139.     {
  140.     private:
  141.         LPVOID      m_pv;                       //Customizable structure
  142.  
  143.     public:
  144.         CPolylineAdviseSink(LPVOID);
  145.         ~CPolylineAdviseSink(void);
  146.  
  147.         void OnPointChange(void);
  148.         void OnSizeChange(void);
  149.         void OnDataChange(void);
  150.         void OnColorChange(void);
  151.         void OnLineStyleChange(void);
  152.     };
  153.  
  154. typedef CPolylineAdviseSink FAR * LPCPolylineAdviseSink;
  155.  
  156.  
  157. //Color indices for color messages
  158. #define POLYLINECOLOR_BACKGROUND    0
  159. #define POLYLINECOLOR_LINE          1
  160.  
  161.  
  162.  
  163. #endif  //_POLYLINE_H_
  164.